package com.iplay.thezen.composite;

/**
 * @author dangwu
 * @since 2021/9/23 3:39 下午
 */
public class Client {
    public static void main(String[] args) {
        Composite root = new Composite();
        root.doSomething();
        Composite branch = new Composite();
        Leaf leaf = new Leaf();
        root.add(branch);
        branch.add(leaf);


    }

    public static void display(Composite root) {
        for (Component c : root.getChildren()) {
            if (c instanceof Leaf){
                c.doSomething();
            }else {
                display((Composite) c);
            }
        }
    }
}
